const { getUserInfo, modifyUsers, collection, getCollection, wxLogin, browse, getBrowse } = require('../dao/modules/usersDao')

// 获取用户信息
module.exports.getUserInfo = async (params) => {
    const data = await getUserInfo(params)
    if (data) {
        return {
            message: '获取用户成功',
            status: 1,
            data
        }
    }
    return {
        message: '获取用户失败',
        status: 0,
        data
    }
}

// 获取用户信息
module.exports.modifyUsers = async (params) => {
    const data = await modifyUsers(params)
    if (data) {
        return {
            message: '修改用户成功',
            status: 1,
            data
        }
    }
    return {
        message: '修改用户失败',
        status: 0,
        data
    }
}

// 收藏和取消收藏
module.exports.collection = async (params) => {
    const data = await collection(params)
    console.log(111, data);
    if (data.code == 0) {
        return {
            message: '收藏成功',
            status: 1,
            data: data.a
        }
    }
    return {
        message: '取消收藏成功',
        status: 0,
        data: data.b
    }
}

// 获取收藏
module.exports.getCollection = async (params) => {
    const data = await getCollection(params)
    if (data) {
        return {
            message: '获取收藏成功',
            status: 1,
            data
        }
    }
    return {
        message: '获取收藏失败',
        status: 0,
        data
    }
}

// 浏览商品
module.exports.browse = async (params) => {
    const data = await browse(params)
    if (data) {
        return {
            message: '新增浏览成功',
            status: 1,
            data
        }
    }
    return {
        message: '新增浏览失败',
        status: 0,
        data
    }
}

// 获取浏览商品
module.exports.getBrowse = async (params) => {
    const data = await getBrowse(params)
    if (data) {
        return {
            message: '获取浏览成功',
            status: 1,
            data
        }
    }
    return {
        message: '获取浏览失败',
        status: 0,
        data
    }
}

// 微信授权登录
module.exports.wxLogin = async (params) => {
    const data = await wxLogin(params)
    if (data.token) {
        return {
            message: '登录成功',
            status: 1,
            data
        }
    }
    return {
        message: '登录失败',
        status: 0,
        data
    }
}